﻿using System;
using System.Windows;
using System.Windows.Markup;
using Garfield.Core.Runtime;

namespace Garfield.Presentation.Markup
{
    [MarkupExtensionReturnType(typeof(UIElement))]
    public sealed class ViewPartExtension : MarkupExtensionBase
    {
        private readonly string identifier;

        public ViewPartExtension(string identifier)
        {
            this.identifier = identifier;
        }

        protected override object ProvideValue(IServiceProvider provider, IServiceLocator locator, IExtensionRegistry registry)
        {
            return registry.GetExtensions(PresentationPlugin.ViewParts).GetExtension(identifier);
        }
    }
}
